	.text
	.align	2
start:
	MOV r0, #array
	B.L sort
	HLT
sort:
	MOV r1, #0
loop0:
	MOV r2, r1
	ADD r2, r2, #1
loop1:
	LDW r3, [r0+], r1<<#2
	LDW r4, [r0+], r2<<#2
	CMPSUB.A r3, r4
	BEL skip
	MOV r5, r1<<#2
	MOV r6, r2<<#2
	STW r3, [r0+], r6
	STW r4, [r0+], r5
skip:
	ADD r2, r2, #1
	CMPSUB.A r2, #8
	BSL loop1
	ADD r1, r1, #1
	CMPSUB.A r1, #7
	BSL loop0
finish:
	JUMP lr

array:
	.long  5
	.long  1
	.long  6
	.long  4
	.long  3
	.long  8
	.long  2
	.long  7
